package C;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class C69 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        System.out.println(getResult(input));
    }

    public static int getResult(String input) {
        String s = input.split(" ")[0];
        int targetIndex = Integer.parseInt(input.split(" ")[1]);
        char[] chars = s.toCharArray();
        Arrays.sort(chars);
        System.out.println(Arrays.toString(chars));
        char target = chars[targetIndex-1];
        System.out.println(target);
        return s.indexOf(target);
    }



}
